package chapter3.test04;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import javax.sql.DataSource;

import vo.UserVO;

public class addStatement implements StatementStrategy {

	DataSource dataSource;
	UserVO user;

	
	public addStatement(UserVO user){
		this.user = user;
	}
	
	public void setDataSource(DataSource dataSource){
		this.dataSource = dataSource;
	}
	
	@Override
	public PreparedStatement makePreparedStatement(Connection c)
			throws SQLException {
		// TODO Auto-generated method stub
		PreparedStatement psmt = c.prepareStatement("insert into users(id,name,password) values (?,?,?)");
		psmt.setString(1, user.getId());
		psmt.setString(2,user.getName());
		psmt.setString(3,user.getPassword());
		return psmt;
	}
}
